package com.jiukuaidao.zhulin.module.home.contract;

import com.jiukuaidao.library.base.IBasePresenter;
import com.jiukuaidao.library.base.IBaseView;
import com.jiukuaidao.zhulin.data.TaskDataSource;
import com.jiukuaidao.zhulin.entity.ApiHomeAds;
import com.jiukuaidao.zhulin.entity.ApiHomePros;
import com.jiukuaidao.zhulin.entity.DBShoppingCartInfo;
import com.jiukuaidao.zhulin.entity.EventShoppingCartInfo;

import java.util.List;

/**
 * Author : H_Joker
 * Date : 2016/5/27
 * Description :
 */
public interface HomeContract {

    int REFRESH = 1;
    int LOADMORE = 2;

    interface View extends IBaseView<Presenter> {

        /**
         * 刷新banner
         *
         * @param imgs    图片链接集合
         * @param actList 图片信息集合
         */
        void refreshBannerUi(List<String> imgs, List<ApiHomeAds.ApiHomeAdItem> actList);

        /**
         * 刷新运营列表
         *
         * @param acts
         */
        void refreshActsUi(List<ApiHomeAds.ApiHomeActItem> acts);

        /**
         * 刷新商品列表
         *
         * @param pros
         */
        void refreshProsUi(List<ApiHomePros.ApiHomeProItem> pros);

        /**
         * recyclerview加载完毕
         *
         * @param act     REFRESH：刷新 LOADMORE：加载更多
         * @param isOver  true：没有更多数据 false：还有数据
         * @param isEmpty true：当前没有数据 false：当前有数据
         */
        void loadComplete(int act, boolean isOver, boolean isEmpty);

        /**
         * 刷新页面上店铺信息
         *
         * @param shopInfo
         */
        void refreshShopInfoUI(ApiHomePros.ApiHomeShop shopInfo);
    }

    interface Presenter extends IBasePresenter {

        /**
         * 获取Model中的购物车
         *
         * @return
         */
        List<EventShoppingCartInfo> getShoppingCart();

        /**
         * 从数据库获取购物车数据放入Model中
         */
        void setShoppingCart(List<EventShoppingCartInfo> list);

        /**
         * 加载商品列表
         *
         * @param act       REFRESH：刷新 ， LOADMORE：夹在更多
         * @param pageIndex 需要加载的页码
         * @param keyWord   关键词
         * @param cityId    城市id
         * @param longitude 经度
         * @param latitude  纬度
         */
        void loadPros(int act, int pageIndex, String keyWord, String cityId, String longitude, String latitude);

        /**
         * 刷新banner和运营位
         *
         * @param cityId
         */
        void refreshAdsAndAct(String cityId);

        void setCurPageIndex(int curPageIndex);

        int getCurPageIndex();

        List<ApiHomePros.ApiHomeProItem> getProList();

        List getActList();

        List getBannerList();

        void setShopInfo(ApiHomePros.ApiHomeShop shop);

        ApiHomePros.ApiHomeShop getShopInfo();
    }

    interface Model extends TaskDataSource {

        List<ApiHomePros.ApiHomeProItem> getProList();

        List<ApiHomeAds.ApiHomeActItem> getActList();

        List<ApiHomeAds.ApiHomeAdItem> getBannerList();

        List<EventShoppingCartInfo> getShoppingCart();

        int getCurPageIndex();

        void setProList(List<ApiHomePros.ApiHomeProItem> list);

        void setActList(List<ApiHomeAds.ApiHomeActItem> list);

        void setBannerList(List<ApiHomeAds.ApiHomeAdItem> list);

        void setCurPageIndex(int curPageIndex);

        void setShoppingCart(List<EventShoppingCartInfo> list);

        void setShopInfo(ApiHomePros.ApiHomeShop shop);

        ApiHomePros.ApiHomeShop getShopInfo();
    }

    /**
     * 读取购物车回调
     */
    interface OnGetCartInfoCallBack {
        void onSuccess(List<DBShoppingCartInfo> mCartInfos);

        void onFail(Throwable throwable);
    }

    /**
     * 增删购物车回调
     */
    interface OnChageCountListener {
        void onSucess();

        void onFail(String msg);
    }

}
